﻿using System;
using ServerApi.Controllers;
using Newtonsoft.Json;
using TuyennvLibrary.Reflection;
using TuyennvLibrary.ServerApi.Controllers;

namespace ServerApi
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (Request.HttpMethod.ToUpper() == System.Configuration.ConfigurationManager.AppSettings["method"].Trim().ToUpper())
                {
                    Config.Request = Request;
                    Config.domain = Request.Url.ToString().Replace(Request.Url.AbsolutePath, "").Replace(Request.Url.Query, "");
                    Config.Server = Server;
                    object content = Code.error();
                    content = JsonConvert.SerializeObject(TuyennvLibrary.ServerApi.Controllers.ApiController.callApi(Request));

                    //content = ApiController.callApi(Request);
                    //content = new tivi().getconfig("100");
                    Response.Write(content);
                }
                else
                {
                    Response.Write(new { code = Code.ERROR, message = "not data" });
                }
            }
            catch (Exception ex)
            {
                //Utilities.logError(Bluesea.Models.TypeError.Api, ex.ToString());
            }
        }
    }
}
